home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1997 November & December / Amiga-CD 1997 #11-12.iso / online / inetutils-1.4-amitcp / contrib / mailq.rexx < prev    next >
OS/2 REXX Batch file  |  1994-09-30  |  2KB  |  83 lines

  1. /*
  2.  * Scan the InetUtils SMTPd Queue directory, and show us what's going in
  3.  * where what's in the queue is going, and how long it's been there.
  4.  *
  5.  * Copyright  1994, Mike Meyer (mwm@contessa.phone.net)
  6.  */
  7.  
  8. /* Output tuning */
  9. queue_len = 20
  10. host_len = 40
  11.  
  12. /* Make sure we have the libraries */
  13. if ~show('Libraries', 'rexxarplib.library') then
  14.     if ~addlib('rexxarplib.library', 0, -30) then do
  15.         say "No rexxarplib, so we can't scan the spool!"
  16.         exit
  17.         end
  18. if ~show('Libraries', 'rexxsupport.library') then
  19.     if ~addlib('rexxsupport.library', 0, -30) then do
  20.         say "No rexxsupport library, so we can't scan the spool!"
  21.         exit
  22.         end
  23.  
  24. /* Get the SMTPSPoolDir */
  25. spooldir = getuuenv('SMTPSPOOLDIR')
  26. if spooldir = "" then do
  27.     say "Can't find the name of the directory to scan."
  28.     exit
  29.     end
  30. old = pragma('Directory', spooldir)
  31.  
  32. /* Get a list of files in it */
  33. count = filelist('X.#?', files)
  34.  
  35. /* Now, process them */
  36. if count = 0 then
  37.     say "No files in the mail queue"
  38. else do
  39.     say left("Queue number", queue_len) ,
  40.         || left("Destination host", host_len) || "Time in queue"
  41.     say ""
  42.     nowdays = date('Internal')
  43.     nowminutes = time('Minutes')
  44.     do i = 1 to count
  45.         parse value files.i with 'X.'queue
  46.         parse value statef(files.i) with . . . . filedays fileminutes .
  47.         days = nowdays - filedays
  48.         minutes = nowminutes - fileminutes
  49.         if minutes < 0 then do
  50.             days = days + 1
  51.             minutes = minutes + 1440
  52.             end
  53.         hours = 24 * days + minutes % 60
  54.         minutes = minutes // 60
  55.         destination = getdestination(files.i)
  56.         if destination = "" then iterate
  57.         out = left(queue, queue_len) || left(destination, host_len)
  58.  
  59.         select
  60.             when hours = 0 & minutes = 0 then say out || "no time"
  61.             when hours = 0 & minutes = 1 then say out || "1 minute"
  62.             when hours = 0 then say out || minutes "minutes"
  63.             when hours = 1 & minutes = 0 then say out || "1 hour"
  64.             when hours = 1 & minutes = 1 then
  65.                 say out || "1 hour 1 minute"
  66.             when hours = 1 then
  67.                 say out || "1 hour" minutes "minutes"
  68.             when minutes = 0 then say out || hours "hours"
  69.             when minutes = 1 then say out || hours "hours 1 minute"
  70.             otherwise say out || hours "hours" minutes "minutes"
  71.             end
  72.         end
  73.     end
  74. exit
  75.  
  76. getdestination: procedure
  77.     parse arg file
  78.  
  79.     if ~open(in, file, 'Read') then return ""
  80.     host = readln(in)
  81.     call close in
  82.     return host
  83.